package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysDiagnosisTaskMapper;
import com.ruoyi.system.domain.SysDiagnosisTask;
import com.ruoyi.system.service.ISysDiagnosisTaskService;

/**
 * 诊断任务列Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-05-22
 */
@Service
public class SysDiagnosisTaskServiceImpl implements ISysDiagnosisTaskService 
{
    @Autowired
    private SysDiagnosisTaskMapper sysDiagnosisTaskMapper;

    /**
     * 查询诊断任务列
     * 
     * @param companyId 诊断任务列主键
     * @return 诊断任务列
     */
    @Override
    public  List<SysDiagnosisTask> selectSysDiagnosisTaskByCompanyId(Long companyId)
    {
        return sysDiagnosisTaskMapper.selectSysDiagnosisTaskByCompanyId(companyId);
    }

    /**
     * 查询诊断任务列列表
     * 
     * @param sysDiagnosisTask 诊断任务列
     * @return 诊断任务列
     */
    @Override
    public List<SysDiagnosisTask> selectSysDiagnosisTaskList(SysDiagnosisTask sysDiagnosisTask)
    {
        return sysDiagnosisTaskMapper.selectSysDiagnosisTaskList(sysDiagnosisTask);
    }

    /**
     * 新增诊断任务列
     * 
     * @param sysDiagnosisTask 诊断任务列
     * @return 结果
     */
    @Override
    public int insertSysDiagnosisTask(SysDiagnosisTask sysDiagnosisTask)
    {
       List<SysDiagnosisTask>  task=sysDiagnosisTaskMapper.selectSysDiagnosisTaskList(sysDiagnosisTask);
       int row=0;
       if(task.size()>0){
           SysDiagnosisTask work=task.get(0);
           work.setStatus(sysDiagnosisTask.getStatus());
           work.setUpdateTime(DateUtils.getNowDate());

           row=sysDiagnosisTaskMapper.updateSysDiagnosisTask(work);
       }else{
           sysDiagnosisTask.setCreateTime(DateUtils.getNowDate());
           row= sysDiagnosisTaskMapper.insertSysDiagnosisTask(sysDiagnosisTask);
       }


        return row;
    }

    /**
     * 修改诊断任务列
     * 
     * @param sysDiagnosisTask 诊断任务列
     * @return 结果
     */
    @Override
    public int updateSysDiagnosisTask(SysDiagnosisTask sysDiagnosisTask)
    {
        sysDiagnosisTask.setUpdateTime(DateUtils.getNowDate());
        return sysDiagnosisTaskMapper.updateSysDiagnosisTask(sysDiagnosisTask);
    }

    /**
     * 批量删除诊断任务列
     * 
     * @param companyIds 需要删除的诊断任务列主键
     * @return 结果
     */
    @Override
    public int deleteSysDiagnosisTaskByCompanyIds(Long[] companyIds)
    {
        return sysDiagnosisTaskMapper.deleteSysDiagnosisTaskByCompanyIds(companyIds);
    }

    /**
     * 删除诊断任务列信息
     * 
     * @param companyId 诊断任务列主键
     * @return 结果
     */
    @Override
    public int deleteSysDiagnosisTaskByCompanyId(Long companyId)
    {
        return sysDiagnosisTaskMapper.deleteSysDiagnosisTaskByCompanyId(companyId);
    }
}
